#include<stdio.h>
int main()
{
    //freopen("in.txt","r",stdin);
    char c;
    int ans = 0;
    while (scanf("%c",&c) != EOF)
    {
        if(c == '0') break;
        else
        {
            int ans = c-'0';
            while (scanf("%c",&c) && c != '\n')
            {
                ans+=c-'0';
            }
            printf("%d\n",ans);
        }
    }
}